package ink.lovejinhu.swardToOffer;

import java.util.*;

/**
 * @Author: jin
 * @ClassName: Person
 * @Date: 2021/8/22 20:18
 * @Version: V1.0
 **/
public class Offer_045 {
    /**
     * 按字典序排序
     * 这里数组与集合互转还有点问题
     *
     * @param nums
     * @return
     */
    public String minNumber(int[] nums) {
        ArrayList<Integer> temp = new ArrayList<>();
        for (int i = 0; i < nums.length; i++) {
            temp.add(nums[i]);

        }
        Collections.sort(temp, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                String v0 = o1 + "" + o2;
                String v1 = o2 + "" + o1;
                return v0.compareTo(v1);
            }
        });
        StringBuilder res = new StringBuilder();
        for (int i = 0; i < temp.size(); i++) {
            res.append(temp.get(i));
        }

        return res.toString();
    }

    public static void main(String[] args) {
        StringBuilder v0 = new StringBuilder();
        v0.append(1);
        v0.append(1);
        v0.append(1);
        String s = String.valueOf(1);
        System.out.println(v0.toString());


    }
}
